/**
 *Copyright (c) 2024 watereyes
 * safetymanagement is licensed under Mulan PubL v2.
 * You can use this software according to the terms and conditions of the Mulan
 * PubL v2.
 * You may obtain a copy of Mulan PubL v2 at:
 *          http://license.coscl.org.cn/MulanPubL-2.0
 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
 * EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
 * MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
 * See the Mulan PubL v2 for more details.
 */
package com.koron.report.controller;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.koron.common.StaffAttribute;
import com.koron.common.bean.StaffBean;
import com.koron.common.permission.SPIAccountAnno;
import com.koron.purpose.utils.BusinessCode;
import com.koron.report.bean.*;
import com.koron.report.service.api.DangerAnalysisService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.swan.bean.MessageBean;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Api(tags = "dataAnalysis", description = "统计相关接口")
@RestController
@RequestMapping("/dataAnalysis")
public class AnalysisController {
    @Autowired
    private DangerAnalysisService dataAnalysisService;

    @ApiOperation("查看各个子部门的隐患统计分析列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "部门编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/analysisDangerbak.htm", method = RequestMethod.POST)
    public MessageBean<List<DangerAnalysis>> analysisDangerbak(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                            @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                            @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                            @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<List<DangerAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.queryCountDanger(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("查看各个子部门的隐患统计分析列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "部门编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/analysisDanger.htm", method = RequestMethod.POST)
    public MessageBean<List<DangerAnalysis>> analysisDanger(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                            @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                            @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                            @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<List<DangerAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.analysisDanger(updateTimeStart, updateTimeEnd, code);
    }

//    @ApiOperation("展示所有已开通水司的隐患统计分析列表接口")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "水司编码", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
//    })
//    @RequestMapping(value = "/analysisDangerByCorp.htm", method = RequestMethod.POST)
//    public MessageBean<List<DangerAnalysis>> analysisDangerByCorp(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
//                                                                  @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
//                                                                  @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
//                                                                  @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
//        if (null == user) {
//            MessageBean<List<DangerAnalysis>> msg = new MessageBean<>();
//            msg.setCode(BusinessCode.NO_LOGIN.getCode());
//            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
//            return msg;
//        }
//        return dataAnalysisService.queryCountDangerByCorp(updateTimeStart, updateTimeEnd, code);
//    }

    @ApiOperation("查看本部门的隐患统计分析总情况接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "部门code", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/countAnalysisDanger1.htm", method = RequestMethod.POST)
    public MessageBean<DangerAnalysis> countAnalysisDanger(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                           @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                           @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                           @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<DangerAnalysis> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.countDanger(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("获取隐患分类表头接口")
    @RequestMapping(value = "/getTable.htm", method = RequestMethod.GET)
    public MessageBean<List> getTable(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user) {
        if (null == user) {
            MessageBean<List> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.getTable();
    }

    @ApiOperation("查看本部门的隐患统计分析总情况接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "部门code", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/countAnalysisDanger.htm", method = RequestMethod.POST)
    public MessageBean<DangerAnalysis> getCountAnalysisDanger(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                           @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                           @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                           @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<DangerAnalysis> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.getCountAnalysisDanger(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("查看子部门下危险源统计分析列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "部门编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/analysisHazradSource.htm", method = RequestMethod.POST)
    public MessageBean<List<LocalHazarsSourceAnalysis>> analysisHazradSource(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                                             @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                             @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                             @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<List<LocalHazarsSourceAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.queryCountRiskHazardSource(updateTimeStart, updateTimeEnd, code);
    }

//    @ApiOperation("展示所有已开通水司的危险源分析列表接口")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "code", value = "水司编码", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
//            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
//    })
//    @RequestMapping(value = "/analysisHazradSourceByCorp.htm", method = RequestMethod.POST)
//    public MessageBean<List<LocalHazarsSourceAnalysis>> analysisHazradSourceByCorp(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
//                                                                                   @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
//                                                                                   @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
//                                                                                   @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
//        if (null == user) {
//            MessageBean<List<LocalHazarsSourceAnalysis>> msg = new MessageBean<>();
//            msg.setCode(BusinessCode.NO_LOGIN.getCode());
//            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
//            return msg;
//        }
//        return dataAnalysisService.queryCountRiskHazardSourceByCorp(updateTimeStart, updateTimeEnd, code);
//    }

    @ApiOperation("查看当前部门危险源统计分析总情况接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "部门code", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/countAnalysisHazradSource.htm", method = RequestMethod.POST)
    public MessageBean<LocalHazarsSourceAnalysis> countAnalysisHazradSource(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                                            @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                            @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                            @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<LocalHazarsSourceAnalysis> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.countRiskHazardSource(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("查看子部门下任务统计分析列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/taskAnalysis.htm", method = RequestMethod.POST)
    public MessageBean<List<UserTaskAnalysis>> taskAnalysis(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                            @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                            @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                            @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<List<UserTaskAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.queryCountUserTask(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("展示所有已开通水司的任务分析列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "水司code", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/taskAnalysisByCorp.htm", method = RequestMethod.POST)
    public MessageBean<List<UserTaskAnalysis>> taskAnalysisByCorp(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                                  @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                  @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                  @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<List<UserTaskAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.queryCountUserTaskByCorp(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("查看当前部门下任务统计分析总体情况接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司code", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/countAnalysisTask.htm", method = RequestMethod.POST)
    public MessageBean<UserTaskAnalysis> countAnalysisTask(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                           @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                           @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                           @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<UserTaskAnalysis> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.countUserTask(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("查看子部门下检查记录统计分析列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/analysisCheckRecord.htm", method = RequestMethod.POST)
    public MessageBean<List<CheckRecordAnalysis>> queryCountCheckRecord(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                                        @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                        @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                        @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<List<CheckRecordAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.queryCountCheckRecord(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("展示所有已开通水司的检查记录分析列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "水司编码", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/analysisCheckRecordByCorp.htm", method = RequestMethod.POST)
    public MessageBean<List<CheckRecordAnalysis>> queryCountCheckRecordByCorp(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                                              @RequestParam(required = false) final String code,
                                                                              @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                              @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                                              @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<List<CheckRecordAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.queryCountCheckRecordByCorp(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("查看当前部门下检查记录统计分析总体情况接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "片区/水司code", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeStart", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "updateTimeEnd", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/countAnalysisCheckRecord.htm", method = RequestMethod.POST)
    public MessageBean<CheckRecordAnalysis> countCheckRecord(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                                             @RequestParam(required = false) final String code, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                             @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeStart, @RequestParam(required = false) final @JsonFormat(pattern = "yyyy-MM-dd")
                                                             @DateTimeFormat(pattern = "yyyy-MM-dd") Date updateTimeEnd) {
        if (null == user) {
            MessageBean<CheckRecordAnalysis> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.countCheckRecord(updateTimeStart, updateTimeEnd, code);
    }

    @ApiOperation("易发生事故类型统计接口,根据公司，时间段进行统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "code", value = "水司code", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "开始时间", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "结束时间", dataType = "String", paramType = "query")
    })
    @RequestMapping(value = "/accidentAnalysis.htm", method = RequestMethod.POST)
    public MessageBean<List<AccidentBulletinAnalysis>> accidentAnalysis(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,
                                             @RequestParam(required = false) final String code, @RequestParam(required = false) String startTime,  @RequestParam(required = false)String endTime) {
        if (null == user) {
            MessageBean<List<AccidentBulletinAnalysis>> msg = new MessageBean<>();
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        return dataAnalysisService.getAccidentAnalysis(code, startTime, endTime);
    }

    @ApiOperation("首页工作台，隐患,安全检查(年/月)，作业票数量统计接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "corpCode", value = "水司code", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "startTime", value = "查询开始日期", dataType = "String", paramType = "query"),
            @ApiImplicitParam(name = "endTime", value = "查询结束日期", dataType = "String", paramType = "query"),
    })
    @RequestMapping(value = "/homePageAnalysis.htm", method = RequestMethod.POST)
    public MessageBean<Map> homePageList(@SPIAccountAnno @StaffAttribute("_user") @ApiIgnore StaffBean user,String userCode, @RequestParam(required = false) final String corpCode,
                                         @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime, @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime) {
        MessageBean<Map> msg = new MessageBean<>();
        if (null == user) {
            msg.setCode(BusinessCode.NO_LOGIN.getCode());
            msg.setDescription(BusinessCode.NO_LOGIN.getDescription());
            return msg;
        }
        msg = dataAnalysisService.homePageAnalysis(user, corpCode, startTime, endTime);
        return msg;
    }

}
